package com.atos.optical.controller;

import com.atos.optical.common.ApiResult;
import com.atos.optical.common.BaseHttpController;
import com.atos.optical.model.po.SysOrderInfo;
import com.atos.optical.model.query.SysOrderInfoQuery;
import com.atos.optical.service.SysOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wanghra
 * @version 1.0
 * @description
 * @date 2025/8/15
 */
@RestController
@RequestMapping("/order/info")
public class SysOrderInfoController extends BaseHttpController {
    @Autowired
    private SysOrderInfoService service;

    @PostMapping("/save")
    public ApiResult<Boolean> save(@RequestBody SysOrderInfo entity) {
        return new ApiResult<>(service.save(entity));
    }

    @PostMapping("/update")
    public ApiResult<Boolean> update(@RequestBody SysOrderInfo entity) {
        return new ApiResult<>(service.updateById(entity));
    }

    @DeleteMapping("/delete/{id}")
    public ApiResult<Boolean> delete(@PathVariable("id") String id) {
        return new ApiResult<>(service.removeById(id));
    }

    @GetMapping("/getById/{id}")
    public ApiResult<SysOrderInfo> getById(@PathVariable("id") String id) {
        return new ApiResult<>(service.getById(id));
    }

    @GetMapping("/page")
    public ApiResult<SysOrderInfoQuery> pageByQuery(SysOrderInfoQuery query) {
        return new ApiResult<>(service.pageByQuery(query));
    }
}
